<div class="page-header">
    <h1>
        Form Add Member
        <small>
            <i class="icon-double-angle-right"></i>
            Penambahan member pada jaringan
        </small>
    </h1>
</div>

<?php 
if ($this->msg) {
    ?>
    <div class="alert alert-danger">
        <button type="button" class="close" data-dismiss="alert">
            <i class="icon-remove"></i>
        </button>

        <strong>
            <i class="icon-remove"></i>
            Error
        </strong>

        <?php echo $this->msg; ?>
        <br />
    </div>
    <?php
}
    ?>

    <div class="row">
        <div class="col-xs-11">
            <form id="formAdd" class="form-horizontal" role="form" action="" method="post">
                <div class="form-group">
                    <label class="col-sm-2 control-label no-padding-right" for="sponsorId"> Sponsor </label>
					
					<div class="col-sm-9">
                        <select class="width-30 chosen-select" id="sponsorId" name="sponsorId" data-placeholder="Pilih Sponsor...">
                            <option value="<?php echo $this->data['sponsorId']; ?>" selected=""> <?php echo $this->data['sponsorName']; ?> - <?php echo$this->data['sponsorCode']; ?></option>
                            <?php
							foreach($this->uplines as $upline){
								echo '<option value="' . $upline['member_id'] . '">' . $upline['member_name']. ' - ' .$upline['member_code'] . '-' . '  ['.$upline['cnt'].']</option>';
							}
                           
                            ?>
						</select>
					</div>
					<!--
                    <div class="col-sm-9">
                        <input type="hidden" name="sponsorId" value="<?php echo $this->data['sponsorId']; ?>" />
                        <input readonly="" type="text" id="sponsorName" name="sponsorCode" placeholder="Sponsor" value="<?php echo $this->data['sponsorCode']; ?>" class="col-xs-10 col-sm-5" />
                    </div>
					-->
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label no-padding-right" for="parentId">Upline</label>
                    <div class="col-sm-9">
                        <select class="width-30 chosen-select" id="parentId" name="parentId" data-placeholder="Pilih Upline...">
						
							<?php
							if(isset($this->parent)){
								foreach($this->uplines as $upline){
									if($this->parent == $upline['member_id']){
										echo '<option value="' . $upline['member_id'] . '">' . $upline['member_name']. ' - ' .$upline['member_code'] . '-' . '  ['.$upline['cnt'].']</option>';
									}
								}	
							}else {
							?>
                            <option value="<?php echo $this->data['sponsorId']; ?>" selected=""> <?php echo $this->data['sponsorName']; ?> - <?php echo$this->data['sponsorCode']; ?></option>
                            <?php
							foreach($this->uplines as $upline){
								echo '<option value="' . $upline['member_id'] . '">' . $upline['member_name']. ' - ' .$upline['member_code'] . '-' . '  ['.$upline['cnt'].']</option>';
							}
                            }?>
						</select>
					</div>
				</div>
            <div class="form-group">
                <label class="col-sm-2 control-label no-padding-right" for="code"> Serial Number </label>

                <div class="col-sm-9">
                    <input type="text" id="code" name="code" placeholder="Serial Number" class="col-xs-10 col-sm-5" value="<?php if (isset( $this->data['code'] )) { echo $this->data['code'];} ?>" required />
                </div>
            </div>
			<div class="form-group">
                <label class="col-sm-2 control-label no-padding-right" for="code"> Pin Number </label>

                <div class="col-sm-9">
                    <input type="password" id="pin" name="pin" placeholder="Pin Number" class="col-xs-10 col-sm-5" value="" required />
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label no-padding-right" for="name"> Nama </label>

                <div class="col-sm-9">
                    <input type="text" id="name" name="name" placeholder="Nama" class="col-xs-10 col-sm-5" value="<?php if (isset($this->data['name'])) { echo $this->data['name']; } ?>" required />
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label no-padding-right" for="ktp"> Nomor KTP </label>

                <div class="col-sm-9">
                    <input type="text" id="ktp" name="ktp" placeholder="Nomor KTP" class="col-xs-10 col-sm-5" value="<?php if(isset($this->data['ktp'])){ echo $this->data['ktp']; }?>" required />
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label no-padding-right" for="mobile"> Nomor Handphone </label>

                <div class="col-sm-9">
                    <input type="text" id="mobile" name="mobile" placeholder="Nomor Handphone" class="col-xs-10 col-sm-5"  value="<?php if(isset($this->data['mobile'])){ echo $this->data['mobile']; }?>" required />
                </div>
            </div>
            <div class="clearfix form-actions">
                <div class="col-md-offset-3 col-md-9">
                    <button class="btn btn-info" type="submit">
                        <i class="icon-ok bigger-110"></i>
                        Submit
                    </button>

                    &nbsp; &nbsp; &nbsp;
                    <button class="btn" type="reset">
                        <i class="icon-undo bigger-110"></i>
                        Reset
                    </button>
                </div>
            </div>
        </form>
    </div>
</div>
